package com.authine.cloudpivot.ext.entity.order.extendsAttr;

import com.authine.cloudpivot.ext.enums.order.OrderReturnBehaviorEnum;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 退款审批记录
 * flowable审批流程结束后返回的审批流程结果信息
 *
 * @author 张天赐
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class OrderGoodsReturnsLog implements Serializable {
    private static final long serialVersionUID = 1851184320840773238L;
    /**
     * 操作人 角色+人名称
     */
    private String operator;
    /**
     * 操作人平台用户ID
     */
    private Long operatorUserId;
    /**
     * 操作行为
     */
    private String behavior;
    /**
     * 备注
     */
    private String memo;
    /**
     * 创建时间
     */
    private LocalDateTime time;

    public static String getBehavior(Integer behaviorId) {
        switch (behaviorId) {
            case 0:
                return "申请退款";
            case 1:
                return "同意退款";
            case 2:
                return "拒绝退款";
            case 3:
                return "发起退货物流";
            case 4:
                return "确认到货";
            case 5:
                return "财务已确认";
            default:
                return "";
        }
    }

    public static OrderGoodsReturnsLog build(OrderReturnBehaviorEnum behavior, String memo, Long operatorUserId, String operator) {
        return OrderGoodsReturnsLog.builder()
                .behavior(behavior.des)
                .memo(memo)
                .operatorUserId(operatorUserId)
                .operator(operator)
                .time(LocalDateTime.now())
                .build();
    }

}
